home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / Linux Fortune.php < prev    next >
Encoding:
Text File  |  2001-07-02  |  3.7 KB  |  125 lines

  1.     //**************************************
  2.     //     
  3.     // Name: Linux Fortune
  4.     // Description:Very primitive include to
  5.     //     show Linux fortune, with an option to sh
  6.     //     ow offensive, plus disk space usage, and
  7.     //     , optional process listing. by Van
  8.     // By: PHP Code Exchange
  9.     //**************************************
  10.     //     
  11.     
  12.     <html> 
  13.     <head> 
  14.     <% 
  15.     /* 2000-06-02 22:01:34: Van; vanboers@dedserius.com 
  16.     http://www.dedserius.com 
  17.     --fortune.php3 v.0.0.1 
  18.     A little PHP3 module for Linux that shows fortune, disk-space usage and 
  19.     processes (if you enable them) 
  20.     $ps_array("cpu","ruser","pid","tty","time","command"); 
  21.     */ 
  22.     %> 
  23.     <title>Fortune on <%=$SERVER_NAME%></title> 
  24.     <table width="100%"> 
  25.     </head> 
  26.     <body bgcolor="white"> 
  27.     <td width=5> 
  28.     </td> 
  29.     <td> 
  30.     <h2> Brought to you by Linux Fortune on <u><% echo "$SERVER_NAME!"%></u></h2> 
  31.     <form action="./fortune.php3" method="get"> 
  32.     <input type="hidden" name="curpage" value="fortune"> 
  33.     <input type="hidden" name="message" value="fortune.php3"> 
  34.     <select name="whichcmd"> 
  35.     <option selected value="<%=$whichcmd%>">Show me a Fortune</option> 
  36.     <option value="FortuneOffensive">Show me an Offensive Fortune</option> 
  37.     <%/*<option value="Who">Who's on the server?</option>*/%> 
  38.     <option value="ProcessList">Show Processes</option> 
  39.     <option value="DF">How are the disks doing?</option> 
  40.     <input type="submit" value="Post"> 
  41.     </select> 
  42.     <input type="hidden" name="chosewhat" value="Fortune"> 
  43.     </form> 
  44.     <% 
  45.     switch ($whichcmd) 
  46.     { 
  47.     case "Fortune": 
  48.     $fortune = exec("/usr/games/fortune -a",$fortunearray); 
  49.     break; 
  50.     case "OffensiveFortune": 
  51.     $fortune = exec("/usr/games/fortune -o",$fortunearray); 
  52.     break; 
  53.     case "Who": 
  54.     $fortune = exec("w", $fortunearray); 
  55.     break; 
  56.     case "DF": 
  57.     $fortune = exec("df -hv | sed '/ /s// /g' | sort -n +1", $fortunearray); 
  58.     $numcols=5; 
  59.     break; 
  60.     case "ProcessList": 
  61.     //Enable the following and comment out t
  62.     //     he one below it, if you're either brave 
  63.     //     
  64.     //or sttupid. >:) The formatting is k
  65.     //     inda broken, but, I haven't done much wi
  66.     //     th it. 
  67.     /*$fortune = exec("ps -eo '%C%u%p%y%x%a' --width 200 | sort -n +1 -r", $fortunearray);*/ 
  68.     $fortune = exec("/bin/echo 'Hi There, >:); Yeah, right!'", $fortunearray); 
  69.     $numcols=5; 
  70.     break; 
  71.     default: 
  72.     $fortune = exec("/usr/games/fortune -a", $fortunearray); 
  73.     break; 
  74.     } 
  75.     $i = 0; 
  76.     $j = count($fortunearray); 
  77.     if ( ($whichcmd != "DF" ) && ($whichcmd != "ProcessList")) 
  78.     { 
  79.     while ( $i < $j ) 
  80.     { 
  81.     echo "<font face=>\n"; 
  82.     echo "$fortunearray[$i]<br>\n"; 
  83.     echo "</font>\n"; 
  84.     $i++; 
  85.     } 
  86.     } else { 
  87.     %> 
  88.     <table border=1> 
  89.     <% 
  90.     while ( $i < $j ) 
  91.     { 
  92.     echo "\t<tr>\n"; 
  93.     $tabarray=split(" ",$fortunearray[$i],$numcols); 
  94.     for ($k=0; $k < $numcols; $k++) 
  95.     { 
  96.     echo "\t\t<td><b>$tabarray[$k] </b></td>\n"; 
  97.     } 
  98.     echo "\t</tr>\n"; 
  99.     $i++; 
  100.     } 
  101.     echo "\n</table>\n"; 
  102.     } 
  103.     %> 
  104.     <% 
  105.     echo "<br><br><hr>\n"; 
  106.     $w = exec("/usr/bin/uptime",$uptime); 
  107.     $e = 0; 
  108.     $f = count($uptime); 
  109.     echo "<b><u><font size=+1>$HostName</u></b> Up Time:</font><br>\n"; 
  110.     echo "==============================================================<br>\n"; 
  111.     while ( $e < $f ) 
  112.     { 
  113.     echo "$uptime[$e]<br>\n"; 
  114.     $e ++; 
  115.     } 
  116.     echo "==============================================================<br>\n"; 
  117.     echo "\n"; 
  118.     %> 
  119.     </td> 
  120.     <td width=5> 
  121.     </td> 
  122.     </table> 
  123.     </body> 
  124.     </html>
  125.